package com.aca.market.entity;

import com.aca.market.common.SerializerBigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 订单表
 * </p>
 *
 * @author aca
 * @since 2020-11-13
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
//@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,property = "indentId")
public class Indent implements Serializable {


    private static final long serialVersionUID=1L;

    /**
     * 订单id
     */
    @TableId(value = "indent_id", type = IdType.AUTO)
    private Long indentId;

    /**
     * 实付金额
     */
    @JsonSerialize(using = SerializerBigDecimal.class)
    private BigDecimal payment;

    /**
     * 支付类型 1在线支付 2货到付款
     */
    private Integer paymentType;

    /**
     * 邮费
     */

    @JsonSerialize(using = SerializerBigDecimal.class)
    private BigDecimal postFee;

    /**
     * 状态 0未付款 1已付款 2未发货 3已发货 4交易成功 5交易关闭 6交易失败
     */
    private Integer status;

    /**
     * 订单创建时间
     */
    @JsonIgnore
    private LocalDateTime createTime;

    /**
     * 订单更新时间
     */
    @JsonIgnore
    private LocalDateTime updateTime;

    /**
     * 付款时间
     */
    @JsonIgnore
    private LocalDateTime paymentTime;

    /**
     * 发货时间
     */
    //只精确到分
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime consignTime;

    /**
     * 交易完成时间
     */
    @JsonIgnore
    private LocalDateTime endTime;

    /**
     * 交易关闭时间
     */
    //只精确到分
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime closeTime;

    /**
     * 物流名称
     */
    private String shippingName;

    /**
     * 物流单号
     */
    private String shippingCode;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 买家留言
     */
    private String buyerMessage;

    /**
     * 买家昵称
     */
    private String buyerName;

    //地址id
    private Long addressId;

    //电话
    private String phone;

}
